package com.icinfo.cloud.provider.punish.service.impl;

import cn.hutool.core.collection.CollUtil;
import com.icinfo.cloud.provider.punish.mapper.CaseReasonMainRecordMapper;
import com.icinfo.cloud.provider.punish.service.ICaseReasonMainRecordService;
import com.icinfo.cloud.provider.punish.ucase.casemain.model.CaseReasonMainRecord;
import com.icinfo.framework.core.service.support.MyBatisServiceSupport;
import com.icinfo.framework.mybatis.mapper.entity.Example;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 描述: 案件案由记录表- case_reason_main_record 对应的Service接口实现类.<br>
 */
@Service
public class CaseReasonMainRecordImpl extends MyBatisServiceSupport implements ICaseReasonMainRecordService {
    @Resource
    private CaseReasonMainRecordMapper caseReasonMainRecordMapper;

    /**
     * 根据案件id查询是否含有公安委托执法并且状态为有效的案件信息
     *
     * @param caseId 案件id
     * @return
     */
    @Override
    public Boolean getIsContainPublicSecurityByCaseId(String caseId) {
        Example example = new Example(CaseReasonMainRecord.class);
        example.createCriteria().andEqualTo("caseId", caseId)
                .andEqualTo("isPublicSecurity", "1")
                .andEqualTo("status", "1");
        List<CaseReasonMainRecord> caseReasonMainRecords = caseReasonMainRecordMapper.selectByExample(example);
        return CollUtil.isNotEmpty(caseReasonMainRecords);
    }
}
